package com.ruoyi.customer.controller;

import com.ruoyi.common.core.utils.PageUtils;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.customer.api.domain.ZkxcUser;
import com.ruoyi.customer.api.domain.ZkxcUserDTO;
import com.ruoyi.customer.domain.ZkxcUserVO;
import com.ruoyi.customer.service.IZkxcUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 推送给设备的用户信息Controller
 *
 * @author ruoyi
 * @date 2025-09-05
 */
@RestController
@RequestMapping("/zkxcUser")
public class ZkxcUserController extends BaseController {
    @Autowired
    private IZkxcUserService zkxcUserService;


    /**
     * 查询推送给设备的用户信息列表
     */
    @PostMapping("/list")
    public TableDataInfo list(@RequestBody ZkxcUserDTO dto) {
        PageUtils.startPage(dto.getPageNum(), dto.getPageSize());
        List<ZkxcUser> list = zkxcUserService.selectZkxcUserList(dto);
        return getDataTable(list);
    }

    @GetMapping("/getRegistrationList")
    public AjaxResult getRegistrationList() {
        ZkxcUserDTO zkxcUserDTO = new ZkxcUserDTO();
        zkxcUserDTO.setStatus(0);
        List<ZkxcUser> list = zkxcUserService.selectZkxcUserList(zkxcUserDTO);
        return AjaxResult.success(list);
    }

    @GetMapping("/selectZkxcUserById/{id}")
    public AjaxResult selectZkxcUserById(@PathVariable("id") Long id) {
        ZkxcUser zkxcUser = zkxcUserService.selectZkxcUserById(id);
        return AjaxResult.success(zkxcUser);
    }

    /**
     * 新增推送给设备的用户信息
     */
    @Log(title = "推送给设备的用户信息", businessType = BusinessType.INSERT)
    @GetMapping("/toExamine/{customerId}")
    public AjaxResult toExamine(@PathVariable Long customerId) {
        return zkxcUserService.insertZkxcUser(customerId);
    }

    /**
     * 修改推送给设备的用户信息
     */
    @PostMapping(value = "/updateZkxcUser")
    public AjaxResult updateZkxcUser(@RequestBody ZkxcUser zkxcUser) {
        return toAjax(zkxcUserService.updateZkxcUser(zkxcUser));
    }

    /**
     * 免登陆接口
     * 用户填写基本信息生成体检记录
     */
    @PostMapping(value = "/createZkxcUser")
    public AjaxResult createZkxcUser(@RequestBody ZkxcUserVO vo) {
        return zkxcUserService.createZkxcUser(vo);
    }
}
